﻿Imports System.Data.SqlClient

Public Class FormCategoryeditor

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Cmd.Parameters("@CategoryName") = Me.txtCategoryName.Text

        Cmd.Parameters("@TypeId") = Me.txttype.Text

        If Me.txtCategoryrId.Text = "" Then
            Cmd.ExecuteNonQuery("INSERT INTO Category VALUES(@CategoryName,@TypeId,1);")
        Else
            Cmd.Parameters("@CategoryId") = txtCategoryrId.Text
            Cmd.ExecuteNonQuery("UPDATE Category SET CategoryName=@CategoryName,TypeId=@TypeId  WHERE CategoryId=@CategoryId")
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
End Class